<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

   

    <input class="user" type="text" placeholder="手机号">
    <br>
    <input class="pwd" type="text">
    <br>
    <button>登录</button>


    <script>

        const oBtn = document.querySelector('button') ;
        const oUser = document.querySelector('.user') ;
        const oPwd = document.querySelector('.pwd') ;

        


        oBtn.onclick = function() {
            // 获取用户名和密码
            const tel = oUser.value ;
            const pwd = oPwd.value ;

          
            // 判断手机号是否存在
            const res = localStorage.getItem('YYDS_' + tel) ;
            console.log(res);
            
            if(res) {
                // 字符串转成对象
                const obj = JSON.parse(res) ;
                if(obj.pwd === pwd) {
                    alert('ok') ;
                    // 记住登录的用户
                    localStorage.setItem('LOGIN_USER' , obj.user) ;
                    location.href= './15list.html'
                } else {
                    alert('err')
                }
            } else {
                alert('手机号错误') ;
            }

        }

    </script>
    
</body>
</html>